import java.util.Random;
import java.util.Scanner;

public class GuessNumber {public static void main(String[] args) {
    Random r = new Random();
    int num = r.nextInt(10) + 1;// 范围是[1,100]
    Scanner sc = new Scanner(System.in);

    int i = 0;
    while(i < 3){
        System.out.println("请猜测一个数字：");
        int guessnum = sc.nextInt();
        if( guessnum > num ){
            i++;
            if(i > 2){
                System.out.println("猜测次数已用完，请重新开始游戏！");
                break;
            }
            System.out.println("太大了，请重猜");
        }else if (guessnum < num){
            i++;
            if(i > 2){
                System.out.println("猜测次数已用完，请重新开始游戏！");
                break;
            }
            System.out.println("猜小了，请重猜");
        }else{
            System.out.println("恭喜您！猜对啦！");
            break;
        }
    }
}

}
